package club.emergency.wechat.question.operate;

import club.emergency.wechat.model.question.Question;
import club.emergency.wechat.model.question.QuestionDailyRecord;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Create with IntelliJ IDEA
 * Project Name: business
 * Package Name: club.emergency.safetytraining.question.operate
 * Date: 2018/11/28
 *
 * @author: 快乐的小菌菌
 * Description:
 */
public interface QuestionOperate {
    /**
     * 新增试题
     *
     * @param question         试题pojo
     * @param choiceOptionList 选项list Json串
     * @return 以字符串形式返回
     */
    @PostMapping("/question-operate-provider/save")
    String save(@RequestBody Question question, @RequestParam("choiceOptionList") String choiceOptionList);

    /**
     * 从excel中导入试题
     *
     * @param suffix 后缀名
     * @param bytes  输入流数组
     * @return 以字符串形式返回
     */
    @PostMapping("/question-operate-provider/saveFromExcel")
    String saveFromExcel(@RequestParam("suffix") String suffix, @RequestBody byte[] bytes);

    /**
     * 修改试题 id能不为null
     *
     * @param question         试题pojo
     * @param choiceOptionList 选项list Json串
     * @return 以字符串形式返回
     */
    @PostMapping("/question-operate-provider/modify")
    String modify(@RequestBody Question question, @RequestParam("choiceOptionList") String choiceOptionList);

    /**
     * 删除试题，需要注意用到该试题的地方需要进行对应处理
     *
     * @param id                 id
     * @param choiceOptionIdList 选项IdList Json串
     * @return 以字符串形式返回
     */
    @PostMapping("/question-operate-provider/remove")
    String remove(@RequestParam("id") Long id, @RequestParam(value = "choiceOptionIdList", required = false) String choiceOptionIdList);

    /**
     * 判断日常答题选项是否正确
     *
     * @param questionDailyRecord   题目pojo
     * @param userOption 用户选择的选项
     * @return 以字符串形式返回
     */
    @PostMapping("/question-search-provider/checkCorrectForDaily")
    String checkCorrectForDaily(@RequestBody QuestionDailyRecord questionDailyRecord, @RequestParam("userOption") String userOption);
}
